library(ncdf)
#### working with multiple files ###############################################

dirpath <- "C:/Users/Steffi/Documents/=Uni/Projektarbeit/TagTRMM"

## list all files in dirpath with that have 'dataset' in their name
fnames <- list.files(dirpath, recursive = T, pattern = ".nc")

## read in all files in 'names_list' - returns list with data frames
data_list <- lapply(1:length(fnames), function(i) {
  open.ncdf(paste(dirpath, fnames[i], sep = "/"), write = F, readumlim = T)
  }
                    )

Prec <- lapply(1:length(data_list), function(i) {
  get.var.ncdf(data_list[[i]], varid = "precipitation")
  }
            )

##auf ein Listenelement zugreifen
Prec[[2]]

##transposed
PrecTran <- lapply(1:length(data_list), function(i) t(Prec[[i]]) )

Prec_cut <- lapply(1:length(Prec), function(i) {
 cut_matrix(Prec[[i]], Res = 0.25, LongMin = 37, LongMax = 37, LatMin = -3.5, 
            LatMax = -3.5)
 }
             )